#include "MainWindow.h"
#include "ui_MainWindow.h"

#include <QDebug>
#include <QFile>

#include "AzModel.h"
#include "AzRecord.h"
#include "AzXmlFileDataSource.h"

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);
	mModel = new AzModel();
    connect(mModel,SIGNAL(calcField(const QModelIndex&,QVariant&)),this,SLOT(calcField(const QModelIndex&,QVariant&)));
    AzXmlFileDataSource *ds = new AzXmlFileDataSource(mModel);
    ds->setFileName("RecInserted.xml");
    mModel->setDataSource(ds);
    mModel->open();
    ui->treeView->setModel(mModel);
}


MainWindow::~MainWindow() {
	delete mModel;
    delete ui;
}

void MainWindow::calcField(const QModelIndex& index,QVariant& val)  {
    val = AzRecord::recordStateString(mModel->record(index)->recordState());
}
